Skip to content

fix(infra): turn off the Ansible color of every playbook run - #5381

Merged
dan-petty merged 3 commits into
mainfrom
fix/5352-infra-plan-no-color
Nov 13, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/5352-infra-plan-no-color

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Every ansible-runner run of a playbook (the plan, the fresh check and the run of an apply) now gets ANSIBLE_NOCOLOR=True and ANSIBLE_FORCE_COLOR=False.

ansible-runner gives the run a pseudo-terminal, and the process runner passes the TERM of the person. In a color terminal, the default callback put color codes around the text of each event. The plan reads the skip result after => as JSON. A result in color does not read, so a skip by a false when was unchecked in a color terminal and not with no terminal. Thus a plan made with no TERM stopped its apply in a color terminal at the fresh check. ANSIBLE_FORCE_COLOR=False replaces a force_color of the repo's ansible.cfg, which Ansible applies after ANSIBLE_NOCOLOR. A skip result that does not read stays unchecked: the safe side.

A plan made in a color terminal before this change can stop at the fresh check. Make the plan again.

Closes #5352

Change: openspec/changes/archive/2026-11-13-5352-infra-plan-no-color/

ansible-runner gives ansible-playbook a pseudo-terminal, and the process
runner passes TERM from the person. In a color terminal the default
callback puts color codes around the text of each event. The plan reads
a skip result in color as unchecked, so a plan with no terminal and its
apply in a color terminal disagree at the fresh check.

The plan, the fresh check and the run now set ANSIBLE_NOCOLOR=True. A
skip result that does not read stays unchecked.

Closes #5352
ansible/utils/color.py applies ANSIBLE_FORCE_COLOR after ANSIBLE_NOCOLOR.
A repo whose ansible.cfg sets force_color thus got color codes in each
event with ANSIBLE_NOCOLOR only, and the plan counted each skip by a
false when as unchecked. The run now also gets ANSIBLE_FORCE_COLOR=False,
which replaces the setting of ansible.cfg.
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/infra Docker container images, DevContainers, and infrastructure tooling labels Nov 13, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results and checks (branch head cec580493, rebased on origin/main at 4ef7c6f11):

  • Fail-to-pass: uv run devops ci fail-to-pass --base origin/main gives 2 failed on base and 63 passed. The failed tests on base are tests.commands.test_infra_apply::test_a_plan_with_no_terminal_passes_the_fresh_check_of_its_apply_in_a_color_terminal (the apply stops at the fresh check) and tests.commands.test_infra_plan::test_the_run_is_check_mode_on_the_limit_without_offline_hosts_with_the_key (KeyError: 'ANSIBLE_NOCOLOR').
  • uv run devops ci test tests/infra tests/commands/test_infra_apply.py tests/commands/test_infra_plan.py tests/commands/test_infra_status.py tests/commands/test_infra_onboard.py: 154 passed.
  • uv run devops ci --check --only lint,format,domain,docs,typecheck: pass. uv run devops openspec check and uv run devops openspec archive: pass.
  • Premise (proposal Feasibility): 3 real probe runs with the pinned ansible-core 2.22.0 and ansible-runner 2.4.3. No TERM: 0 of 65 events hold escape codes. TERM=xterm-256color: 21 events hold escape codes, and node-1 and node-3 each get 1 more unchecked task. TERM=xterm-256color with ANSIBLE_NOCOLOR=True: 0 escape codes, and each host plan equals the plan with no TERM.
  • Review fix: ANSIBLE_FORCE_COLOR=False is in the run environment too. A real check-mode run with TERM=xterm-256color and force_color = True in ansible.cfg gives the skip stdout \x1b[0;36mskipping: [localhost] => {"false_condition": false}\x1b[0m with ANSIBLE_NOCOLOR=True only, and skipping: [localhost] => {"false_condition": false} with ANSIBLE_FORCE_COLOR=False too.
  • Render diff: no k8s/ path changes, so no kustomize or helm render diff applies, and nothing restarts.
  • Known failures outside this change: the review_window transcript tests of fix(roadmap): the review_window git transcript does not match the code #4865 fail in a full local run (tests/core/test_git_contract.py, tests/roadmap/project_review/test_review_facts.py::test_the_facts_of_a_version_window).

@dan-petty
dan-petty marked this pull request as ready for review November 13, 2026 07:35
@dan-petty
dan-petty merged commit 5bafb1a into main Nov 13, 2026
23 checks passed
@dan-petty
dan-petty deleted the fix/5352-infra-plan-no-color branch November 13, 2026 11:31
dan-petty pushed a commit that referenced this pull request Nov 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.127.1](v0.127.0...v0.127.1)
(2026-11-13)


### Bug Fixes

* **ci:** alarm at 360 s, one P0 issue, shards by recorded time
([#5377](#5377))
([2abd6ff](2abd6ff))
* **github:** read the plan diff and the release files from the merge
base ([#5401](#5401))
([c54e14c](c54e14c))
* **infra:** turn off the Ansible color of every playbook run
([#5381](#5381))
([5bafb1a](5bafb1a)),
closes [#5352](#5352)
* install-tools --check passes an older openspec binary
([#5355](#5355))
([625c89d](625c89d))
* **k8s:** allow only the Ingress origins in Open WebUI
([#5357](#5357))
([fdab229](fdab229))
* **pr:** count only the latest run of each check
([#5393](#5393))
([634dc91](634dc91))
* **review:** drop the fixed gateway URL of the review dry run
([#5399](#5399))
([0666d3d](0666d3d))
* **review:** review a pull request at the merge base of its base branch
([#5387](#5387))
([351ba2a](351ba2a)),
closes [#5346](#5346)
* **roadmap:** end fix-plan at a time budget with a result line
([#5380](#5380))
([20468f4](20468f4)),
closes [#5363](#5363)
* **roadmap:** refine skips an item that changed during the write
([#5392](#5392))
([a863dda](a863dda))
* **roadmap:** stage writes RENAMED and REMOVED spec deltas
([#5367](#5367))
([4abbbd2](4abbbd2))
* **roadmap:** title the delivery by the summary of its plan
([#5376](#5376))
([10e1069](10e1069))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/infra Docker container images, DevContainers, and infrastructure tooling type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(infra): a color terminal makes the fresh check differ from the plan

1 participant